import json

from django.http import HttpResponse, HttpRequest
from django.shortcuts import render


def search_form(request):
    return render(request, "search_form.html")


def search_form2(request):
    return render(request, "search_form2.html")


def search_post(req: "HttpRequest"):
    params = req.POST
    para_str = json.dumps(params)
    para_dict = json.loads(para_str)
    print(f"POST表单请求数据:{para_dict}")
    return HttpResponse(para_str)


def search(req: "HttpRequest"):
    req.encoding = "UTF-8"
    qd = req.GET
    # uname = qd['uname']
    # pswd = qd['pswd']
    # rm = qd['remember']
    # content = {'uname': uname, 'pswd': pswd, 'rm': rm}
    str_json = json.dumps(qd)
    re = json.loads(str_json)

    print(f"表单请求数据:{re}")

    return HttpResponse(str_json)

